package com.example.devtool.generate.controller;

import com.example.devtool.core.common.BaseResponse;
import com.example.devtool.generate.controller.request.GenerateRequest;
import com.example.devtool.generate.service.GenerateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhuliangxuan
 * @date 2022/5/21 22:58
 */
@RestController
@RequestMapping("/generate")
public class GenerateController {

    @Autowired
    private GenerateService generateService;

    @RequestMapping("/")
    public BaseResponse<String> generate(@RequestBody GenerateRequest request) {
        try {
            generateService.generate(request);
            return BaseResponse.success("generate success");
        }catch (Exception e) {
            return BaseResponse.error(e.getMessage());
        }
    }
}
